package com.xuyiwei.xblog.business.article.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.xuyiwei.xblog.business.article.dao.TagsMapper;
import com.xuyiwei.xblog.business.article.model.Tags;
import com.xuyiwei.xblog.business.article.service.ITagsService;
import com.xuyiwei.xblog.core.base.constant.enums.CommonStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 文章标签列表 服务实现类
 * </p>
 *
 * @author xuyiwei
 * @since 2018-10-21
 */
@Service
public class TagsServiceImpl extends ServiceImpl<TagsMapper, Tags> implements ITagsService {


    @Override
    public void deleteTagsById(Long id) {
        Tags tags = selectById(id);
        if(tags!=null){
            tags.setStatus(CommonStatusEnum.DELETE.getKey());
            tags.updateById();
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteTagsByIds(List<Long> ids) {
        for(Long id:ids){
            deleteTagsById(id);
        }
    }

    @Override
    public void deleteArticleTags(Long articleId) {
//        Wrapper<> queryWrapper
//        EntityWrapper wrapper=new EntityWrapper();
//        wrapper.setEntity(new User());
//        String name="wang";
//        Integer age=16;
//        ew.where("name = {0}",name).andNew("age > {0}",age).orderBy("age");
//        List<User> list = userService.selectList(ew);
//        Page page2 = userService.selectPage(page, ew);
    }
}
